package org.zs.miracle.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zs.miracle.common.base.dto.BaseLongIdDTO;
import org.zs.miracle.common.base.dto.BaseManyLongIdDTO;
import org.zs.miracle.service.comment.ICommentService;
import org.zs.miracle.service.comment.model.dto.AddCommentDTO;
import org.zs.miracle.service.comment.model.dto.CommentQueryPageDTO;
import org.zs.miracle.service.comment.model.dto.EditCommentDTO;
import org.zs.miracle.service.comment.model.vo.CommentVO;

/**
 * 用户评论表Controller层,接受处理请求
 */
@Tag(name = "用户评论接口")
@RestController
@RequestMapping("/comment")
@AllArgsConstructor
public class CommentController {
  
  @Resource
  ICommentService commentService;
  
  @Operation(summary = "列表查询", description = "列表查询用户评论接口}")
  @GetMapping(value = "/getCommentList", produces = MediaType.APPLICATION_JSON_VALUE)
  @ApiResponse(responseCode = "200", description = "OK")
  
  public List<CommentVO> getList(@Validated BaseLongIdDTO inputDTO) {
    return commentService.getList(inputDTO);
  }
  
  @Operation(summary = "分页查询", description = "分页查询用户评论接口}")
  @GetMapping(value = "/pageQueryList", produces = MediaType.APPLICATION_JSON_VALUE)
  @ApiResponse(responseCode = "200", description = "OK")
  
  public Page<CommentVO> pageQueryList(CommentQueryPageDTO inputDTO) {
    return commentService.pageQueryList(inputDTO);
  }
  
  @Operation(summary = "添加用户评论", description = "添加用户评论接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PostMapping(value = "/addComment", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addComment(@RequestBody @Validated AddCommentDTO inputDTO) {
    return commentService.addComment(inputDTO);
  }
  
  @Operation(summary = "删除用户评论", description = "根据id删除接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @DeleteMapping(value = "/delComment", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean delComment(@RequestBody @Validated BaseManyLongIdDTO inputDTO) {
    return commentService.delComment(inputDTO);
  }
  
  @Operation(summary = "编辑用户评论", description = "编辑用户评论接口")
  @ApiResponse(responseCode = "200", description = "OK")
  @PatchMapping(value = "/editComment", produces = MediaType.APPLICATION_JSON_VALUE)
  public Boolean addComment(@RequestBody @Validated EditCommentDTO inputDTO) {
    return commentService.editComment(inputDTO);
  }
}